package domfarr.web.tapestry.services;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import domfarr.entities.Contact;

public class SimpleContactServiceImpl implements ContactService {

	private List<Contact> contacts;
	private Long index;
	
	public SimpleContactServiceImpl() {
		this.contacts = new ArrayList<Contact>();
		index = 0L;
	}
	
	public Contact save(Contact contact) {
		contact.setId(index);
		this.contacts.add(contact);
		index++;
		
		return this.contacts.get(this.contacts.indexOf(contact));
	}

	public List<Contact> findAll() {
		return Collections.unmodifiableList(this.contacts);
	}

}
